package com.hhb.test;

import com.hhb.model.User;
import com.hhb.service.UserService;
import com.hhb.service.impl.UserServiceImpl;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Demo01 {

    @Test
    public void test01(){

        //1.加载配置文件
        ApplicationContext context = new ClassPathXmlApplicationContext("bean1.xml");

        //2.获取配置创建的对象
        UserService userServiceImpl = context.getBean("userServiceImpl", UserService.class);
        User user = new User();
        user.setUsername("aaa");
        user.setPassword("bbb");
        user.setAge(23);
        userServiceImpl.addUser(user);

    }




}
